package com.bestcem.xm.user.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 退订类型枚举
 *
 * @author ympan <yuming.pan@idiaoyan.com>
 * @version v1.0
 * @date 2022/7/12 11:26
 */
@Getter
@AllArgsConstructor
public enum UnsubscribeTypeEnum {
    /**
     * 指定期限内退订
     */
    SPECIFIED(1, "指定期限内退订"),

    /**
     * 永久退订
     */
    PERMANENT(2, "永久退订");

    private final Integer type;

    private final String desc;

    /**
     * 通过type获取退订类型枚举
     *
     * @param type 索引
     * @return 退订类型枚举
     * @author ympan <yuming.pan@idiaoyan.com>
     * @date 11:27 2022/7/12
     */
    public static UnsubscribeTypeEnum getByType(Integer type) {
        if (type != null) {
            for (UnsubscribeTypeEnum value : values()) {
                if (value.getType().equals(type)) {
                    return value;
                }
            }
        }
        return null;
    }
}
